<?php
/*--------------------------
	file:	safe.inc
	intro:	安全引用
--------------------------*/
//将所有request转换为直接引用的变量
//error_reporting(0);


foreach ( array ('_COOKIE', '_POST', '_GET' ) as $_request ) {
	if (! empty ( $$_request )) {
		foreach ( $$_request as $_key => $_value ) {
			$_key {0} != '_' && $$_key = _addslashes ( $_value );
		}
	}
}
/*foreach(array('_COOKIE', '_POST', '_GET') as $_request) {
	foreach($$_request as $_key => $_value) {
		$getzone = $_request."S[{$_key}]";
		//echo $getzone;
		$_key{0} != '_' && $$getzone = daddslashes($_value);
		print_r($$getzone);
	}
}*/

function _addslashes($string, $force = 0) {
	! defined ( 'MAGIC_QUOTES_GPC' ) && define ( 'MAGIC_QUOTES_GPC', get_magic_quotes_gpc () );
	if (! MAGIC_QUOTES_GPC || $force) {
		if (is_array ( $string )) {
			foreach ( $string as $key => $val ) {
				$string [$key] = _addslashes ( $val, $force );
			}
		} else {
			$string = addslashes ( $string );
		}
	}
	return $string;
}
?>